﻿using System;
using System.Collections;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
using System.IO;
using InfoJetSoft.Service.Entity;
using InfoJetSoft.Service.Util;

namespace InfoJetSoft.Service.Worker
{

	//构造当前表单视图的HTML内容。
	class FormBuildHTMLDocWorker
	{
		
		public static void buildHTMLDoc(Form form)
		{
            //CID 0903 //2011.05.30 //Begin
            XmlDocument htmlDoc = null;
            if (ConfigUtil.PrepareXslt())
            {
                //CID 0678 //2010.11.03 //Begin
                //CID 0755 //2011.01.14 //Begin
                htmlDoc = form.View.Xslt.Transform(form.XmlDoc.DocumentElement, form.XsltArgList);
                //CID 0755 //2011.01.14 //End
                //CID 0678 //2010.11.03 //End
            }
            else
            {
                XmlDocument viewDoc = DOMUtil.buildDoc(form.View.Content);
                XCTransform xslt = new XCTransform(form.Manifest, viewDoc);
                htmlDoc = xslt.Transform(form.XmlDoc.DocumentElement, form.XsltArgList);
            }
            //CID 0903 //2011.05.30 //End

			form.HtmlDoc = htmlDoc;
			form.HtmlNsResolver = new NamespaceResolver(htmlDoc);
			form.XdPrefix = form.HtmlNsResolver.GetPrefix(JetConstant.URI_XD);
		}
		
	}
}